<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>LALALA</title>
    <script>
        function fun() {
            var v = document.getElementsByName("user1");

            var x = new XMLHttpRequest();// 初始化
            x.open("post", "", true);// 异步通知
            x.send("check");
            x.onreadystatechange = function () // 检测状态发生改变
            {
                if (x.readyState === 4 && x.status === 200) {
                    var r = x.responseText;
                    var s = r.split(" ");
                    v[0].value = s[0];
                    v[1].value = s[1];
                    v[2].value = s[2];
                    v[3].value = s[3];
                }
            }
        }
        function set1(p) {
            var x = new XMLHttpRequest();// 初始化
            x.open("post", "", true);// 异步通知
            if (p == 'LED开')
                x.send("which=0sta=1");
            else
                x.send("which=0sta=0");
        }

        function set2(p) {
            var x = new XMLHttpRequest();// 初始化
            x.open("post", "", true);// 异步通知
            if (p == 'weng开')
                x.send("which=1sta=1");
            else
                x.send("which=1sta=0");
        }n
    </script>
</head>

<body>
    光照传感器数据: <input type="text" name="user1"><br>
    加速度x传感器数据：<input type="text" name="user1"><br>
    加速度y传感器数据：<input type="text" name="user1"><br>
    加速度z传感器数据：<input type="text" name="user1"><br>
    <input type="button" name="点" value="刷新" onclick="fun()">
    <br>
    LED:开<input type="radio" name="666" id="LED开" value="1" onclick="set1(id)">
    关<input type="radio" name="666" id="LED关" value="0" onclick="set1(id)"><br>
    蜂鸣器：开<input type="radio" name="777" id="weng开" value="1" onclick="set2(id)">
    关<input type="radio" name="777" id="weng关" value="0" onclick="set2(id)">

</body>

</html>